package com.bupt.controller.system;

import com.bupt.annotation.AccessLimit;
import com.bupt.constants.ResponseResult;
import com.bupt.service.system.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="用户注册操作")
@Slf4j
@RestController
@RequestMapping("/sys_user")
public class SysUserController {

    @Resource
    private SysUserService sysUserService;

    @ApiOperation("用户注册的接口")
    @AccessLimit(interfaceName = "用户注册的接口", isLogIn = false, enable = false)
    @PostMapping("/register/{userName}/{password}/{rePassword}")
    public Object register(@PathVariable("userName") String userName, @PathVariable("password") String password,
                           @PathVariable("rePassword") String rePassword) {
        try {

            Object o = sysUserService.registerUser(userName, password, rePassword);
            return ResponseResult.createOK(o);
        } catch (Exception e) {
            return ResponseResult.createFail(e.getMessage());
        }
    }

}
